using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;

namespace LiteRP
{
    public partial class LiteRenderGraphRecorder
    {
        private static readonly ProfilingSampler s_DrawSkyboxProfilingSampler = new ProfilingSampler("Draw Skybox");
        
        internal class DrawSkyboxPassData
        {
            internal RendererListHandle skyboxRendererListHandle;
        }

        private void AddDrawSkyboxPass(RenderGraph renderGraph, CameraData cameraData)
        {
            using (var builder = renderGraph.AddRasterRenderPass<DrawSkyboxPassData>("Draw Skybox Pass", out var passData, s_DrawSkyboxProfilingSampler))
            {
                passData.skyboxRendererListHandle =renderGraph.CreateSkyboxRendererList(cameraData.camera);
                builder.UseRendererList(passData.skyboxRendererListHandle);

                // 设置渲染Backbuffer
                SetRenderAttachment(builder);
                
                builder.AllowPassCulling(false);

                builder.SetRenderFunc((DrawSkyboxPassData data, RasterGraphContext context) =>
                {
                    context.cmd.DrawRendererList(data.skyboxRendererListHandle);
                });
            }
        }

    }
}